/**
 * Created by YJH on 2018/5/30.
 */
import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
    TouchableOpacity,
    Image,
} from 'react-native';
export default class NavigationBarUtil {

    /**
     * 用于记录在标签页面，用户所设置的标签的状态。
     * */
    static updateArray(array, item) {
        for (var i = 0, len = array.length; i < len; i++) {
            var temp = array[i];
            if (temp === item) {
                array.splice(i, 1);
                return;
            }
        }

        array.push(item);
    }

    /**
     * 用于数组的克隆
     * */
    static cloneArray(from){
        if(!from){return []}
        let array=[];
        for(let i=0,len=from.length;i<len;i++){
            array[i]=from[i];
        }
        return array;
    }

    /** 判断两个数组是否相等*/
    static isArrayEqual(newArray, oldArray){
        if(!(newArray&&oldArray))return false;
        if(newArray.length !== oldArray.length)return false;
        for (let i=0, len=oldArray.length;i<len;i++){
            if(newArray[i] !== oldArray[i]){
                return false;
            }
        }
        return true;
    }


    /** 从数组array中移除元素item的功能 */
    static remove(array, item){
        if(!array)return;
        for(let i=0, len=array.length;i<len;i++){
            if(item===array[i]){
                array.splice(i,1);
            }
        }
    }

}

